package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.ContactDao;
import cn.gson.springboot.model.mapper.ContactMapper;
import cn.gson.springboot.model.pojos.Contact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContactService {
    @Autowired
    ContactMapper contactMapper;
    @Autowired
    ContactDao contactDao;

    public List<Contact> selectAllContact(){
        return contactMapper.selectAllContact();
    }

    public List<Contact> selectContactByCustomer(Integer customerId){
        return contactMapper.selectContactByCustomer(customerId);
    }

    public List<Contact> selectContactByCustomerName(String customerName){
        return contactMapper.selectContactByCustomerName(customerName);
    }

    public List<Contact> selectContactByContactType(Integer contactType){
        return contactMapper.selectContactByContactType(contactType);
    }

    public List<Contact> selectContactBySearchValue(String searchValue){
        return contactMapper.selectContactBySearchValue(searchValue);
    }

    public List<Contact> selectContactByContactName(String contactName){
        return contactMapper.selectContactByContactName(contactName);
    }

    public void addNewContact(Contact contact){
        contactDao.save(contact);
    }
}
